<!DOCTYPE html>
<html lang="zh-cn">
<head>
{include file="public/header" /}
</head>
<body>
<div class="panel admin-panel">
<div class="panel-head"><strong class="icon-menu"> 数据库恢复</strong></div>

<table class="table table-hover text-center">
  <tr>
    <td width="150" align="center">备份名</td>
    <td width="150" align="center">备份时间</td>
    <td width="150" align="center">备份大小</td>
    <td width="100" align="center">卷数</td>
    <td width="100" align="center">压缩</td>
    <td width="100" align="center">状态</td>
    <td width="150" align="center">操作</td>
  </tr>
  {volist name="_list" id="data"}
  <tr class="hover">
    <td width="150" align="center">{$data.time|date='Ymd-His',###}</td>
    <td width="150" align="center">{$key}</td>
    <td width="150" align="center">{$data.size|format_bytes}</td>
    <td width="100" align="center">{$data.part}</td>
    <td width="100" align="center">{$data.compress}</td>
    <td width="100" align="center" class="info">-</td>
    <td width="150" align="center" class="handle">
      <div class="button-group"> 
        <a class="button border-red" href="javascript:if(confirm('您确定要删除吗?')){location.href='{:url('del?time='.$data['time'])}'};"><span class="icon-shanchu"></span> 删除</a> 
        <a class="button border-main confirm-on-click" href="{:url('import?time='.$data['time'])}"><span class="icon-huifu-copy"></span> 导入</a> 
        <a class="button border-main" href="{:url('downFile',array('type'=>'gz','file'=>date('Ymd-His',$data['time'])))}"><span class="icon-xiazai1-copy-copy"></span> 下载</a> 
      </div>
    </td>
  </tr>
  {/volist}
  <tr>
  </tr>
</table>
  </div>
<script src="__HOUTAI__/js/jquery-1.8.2.min.js"></script>

<script type="text/javascript">
$('.confirm-on-click').live('click', function() {
  var self = this,
      status = ".";
  if(confirm('确认导入这项吗？')){
      } else {
      return false;
  }
  $.get(self.href, success, "json");
  window.onbeforeunload = function(){ return "正在还原数据库，请不要关闭！" }
  return false;

  function success(data){
      if(data.code){
          if(data.data.gz){
              data.msg += code;
              if(code.length === 5){
                  code = ".";
              } else {
                  code += ".";
              }
          }
          $(self).parents('tr').find('td.info').text(data.msg);
          $(self).parent().prev().text(data.info);
          if(data.data.part){
              $.get(self.href,
                  {"part" : data.data.part, "start" : data.data.start},
                  success,
                  "json"
              );
          }  else {
              window.onbeforeunload = function(){ return null; }
          }
      } else {
          $(self).parents('tr').find('.info').text(data.msg);
      }
  }
});
</script>
</body>
</html>